#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	int n,a[3];
	cin>>n>>a[0]>>a[1]>>a[2];
	if(a[0]+a[1]+a[2]<=n) printf("1\n");
	else if(a[0]>n||a[1]>n||a[2]>n) printf("0\n");
	else 
	{
		if(a[0]+a[1]<=n) printf("2\n");
		else if(a[0]+a[2]<=n) printf("2\n");
		else if(a[1]+a[2]<=n) printf("2\n");
		else printf("3\n");
	}
	
}
